<%@ page contentType="text/html;charset=utf-8" %>
<%@ page language="java" import="weibo4j.*" %>
<%@ page language="java" import="weibo4j.http.*" %>

<jsp:useBean id="weboauth" scope="session" class="weibo4j.examples.WebOAuth" />
<%
if("1".equals(request.getParameter("opt")))
{
    String wei_url="http://192.168.1.71:8080/WeiBoSina/callback.jsp";
	RequestToken resToken=weboauth.request("http://192.168.1.71:8080/WeiBoSina/callback.jsp");
	if(resToken!=null){
    	String opt=request.getParameter("opt");
	    session.setAttribute("opt",opt);
		out.println(resToken.getToken());
		out.println(resToken.getTokenSecret());
		session.setAttribute("resToken",resToken);
		//String url = resToken.getAuthorizationURL()+"&oauth_callback="+wei_url; 
		response.sendRedirect(resToken.getAuthorizationURL());
		//System.out.print(url);
        //response.sendRedirect(url); 
	}else{
		out.println("request error");
		}
}else{
%>
<a href="call.jsp?opt=1">请点击进行OAuth认证</a>   
<%}%>
<%
if("2".equals(request.getParameter("opt")))
{
    String wei_url="http://192.168.1.71:8080/WeiBoSina/callback.jsp";
	RequestToken resToken=weboauth.request("http://192.168.1.71:8080/WeiBoSina/callback.jsp");	if(resToken!=null){
	    String opt=request.getParameter("opt");
	    session.setAttribute("opt",opt);
		out.println(resToken.getToken());
		out.println(resToken.getTokenSecret());
		session.setAttribute("resToken",resToken);
		//String url = resToken.getAuthorizationURL()+"&oauth_callback="+wei_url; 
		response.sendRedirect(resToken.getAuthorizationURL());

	}else{
		out.println("request error");
		}
}else{
%>
<a href="call.jsp?opt=2">查看我的搜藏</a>
<%}%>
<%
if("3".equals(request.getParameter("opt")))
{
    String wei_url="http://192.168.1.71:8080/WeiBoSina/callback.jsp";
	RequestToken resToken=weboauth.request("http://192.168.1.71:8080/WeiBoSina/callback.jsp");	if(resToken!=null){
	    String opt=request.getParameter("opt");
	    session.setAttribute("opt",opt);
		out.println(resToken.getToken());
		out.println(resToken.getTokenSecret());
		session.setAttribute("resToken",resToken);
		//String url = resToken.getAuthorizationURL()+"&oauth_callback="+wei_url; 
		response.sendRedirect(resToken.getAuthorizationURL());

	}else{
		out.println("request error");
		}
}else{
%>
<a href="call.jsp?opt=3">上传微博图片</a>
<%}%>
   